Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Changes to solve issue #498: Replacing timer implementation #567

Merged
merged 2 commits into from Mar 14, 2016

Conversation

na1taneja2821
Copy link
Contributor

The commit includes changes for replacement of timers code with std::chrono library of C++11. Instead of 2 maps, we now use 3 maps. The extra map stores the starting time_point of the timer and rest the timers map stores the duration of microseconds elapsed in the timer. Since, this works cross-platform, the unnecessary codes have been removed.

long long int totalDuration = timers[timerName].count();
// Converting microseconds to seconds
long long int totalDurationSec = totalDuration / 1e6;
long long int totalDurationMicroSec = totalDuration % 1000000;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not use std::chrono::microseconds::rep here? That would avoid any casting issues.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Converted all the values to std::chrono::duration, to avoid casting issues.

@rcurtin
Copy link
Member

rcurtin commented Mar 14, 2016

Hi there,

Thanks for this nice contribution. I only had a few minor comments. Also it seems like the Windows build failed; could you take a look into this please?

Once those things are handled I'll be happy to merge this in. If you like, please feel free to add your name to the list of contributors in src/mlpack/core.hpp and COPYRIGHT.txt.

@na1taneja2821
Copy link
Contributor Author

Hi,

I made the required changes, but the code failed on some tests that are not affected by the changes. I did not find anything because of which the CoverTreeAlternateMetricTest and SequenceClassificationTest tests failed.

@rcurtin
Copy link
Member

rcurtin commented Mar 14, 2016

Those are random test failures; many of the mlpack tests are probabilistic and it is hard to keep all of them from failing...

Do you want to add your name/email to core.hpp and COPYRIGHT.txt? This looks good to merge otherwise.

@na1taneja2821
Copy link
Contributor Author

I will add my name once I contribute a bit more to mlpack. For now you can merge the branch.

@rcurtin
Copy link
Member

rcurtin commented Mar 14, 2016

I like the change to duration_cast. Personally I think committing one line is enough to be on the list of contributors. Thanks again for the patch, this is a nice improvement. :)

rcurtin added a commit that referenced this pull request Mar 14, 2016
Changes to solve issue #498: Replacing timer implementation
@rcurtin rcurtin merged commit c0886a1 into mlpack:master Mar 14, 2016
@rcurtin
Copy link
Member

rcurtin commented Mar 15, 2016

I made a few changes in 4551dd0, eac547a, and 086a75d. All of these were just style changes, no functionality changes; let me know if I have done anything wrong. I had to do a good amount of minor rewriting to get the lines shorter (80 characters is preferred). Anyway, thanks again! :)

@na1taneja2821
Copy link
Contributor Author

All the changes look good. I will make sure the lines are shorter than 80 characters next time. Also, I had made a habit of not using namespaces, I will surely use the using namespace line whenever necessary. Thanks for changes.

@rcurtin
Copy link
Member

rcurtin commented Mar 16, 2016

Sounds good. There are only a few places in mlpack where we can use using directives; in this case, timers.cpp is a header file, so we can use using to make things shorter. But most other things are header files, so we can't, and the long names end up being necessary...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants